/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.common.i;

import android.graphics.Bitmap;
import android.text.TextUtils;
import java.util.HashMap;

public class r {
    private static HashMap a = new HashMap();
    private static String b = null;

    public static Bitmap a(String paramString) {
        c.a("UIBackgroundBitmapManager", new Object[] { "getBitmap Entry! file = ", paramString });
        if (TextUtils.isEmpty(paramString))
            return null;
        Bitmap localBitmap = null;
        a locala;
        if (a.containsKey(paramString)) {
            locala = (a) a.get(paramString);
            if (locala != null) {
                localBitmap = locala.a;
                locala.b += 1;
            }
        }
        if ((null == localBitmap) && (!(TextUtils.isEmpty(paramString)))) {
            localBitmap = a(paramString, false);
            if (localBitmap != null) {
                locala = new a(null);
                locala.a = localBitmap;
                locala.b += 1;
                a.put(paramString, locala);
            }
        }
        return localBitmap;
    }

    private static Bitmap a(String paramString, boolean paramBoolean) {
        c.a("UIBackgroundBitmapManager", new Object[] { "decodeFromFile Entry! path = ", paramString });
        Bitmap localBitmap = null;
        try {
            localBitmap = b.a(paramString, paramBoolean);
        } catch (Throwable localThrowable) {
            c.b("UIBackgroundBitmapManager", new Object[] { "getBitmap error", localThrowable });
        }
        if (null == localBitmap)
            c.a("UIBackgroundBitmapManager", new Object[] { "decode failed" });
        return localBitmap;
    }

    public static void b(String paramString) {
        c.a("UIBackgroundBitmapManager", new Object[] { "recycleBitmap file = ", paramString });
        if (TextUtils.isEmpty(paramString))
            return;
        if (!(a.containsKey(paramString)))
            return;
        a locala = (a) a.get(paramString);
        if (locala == null)
            return;
        locala.b -= 1;
        if (locala.b > 0)
            return;
        if ((locala.a != null) && (!(locala.a.isRecycled()))) {
            locala.a.recycle();
            locala.a = null;
        }
        a.remove(paramString);
    }

    public static void c(String paramString) {
        b = paramString;
    }

    public static String a() {
        return b;
    }

    private static class a {
        public Bitmap a = null;
        public int b = 0;
    }
}